<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('邀请情况')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input type="hidden" name="resumeId" th:value="${resumeId}"/>
                <div class="select-list">
                    <ul>
                        <li>
                            <p>企业名称：</p>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <p>企业性质：</p>
                            <select name="category" th:with="type=${@dict.getType('job_enterprise_category')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var statusDatas = [[${@dict.getType('job_operate_status')}]];
    var operateResultDatas = [[${@dict.getType('job_operate_result')}]];
    var prefix = ctx + "job/enterprise";
    var invitePrefix = ctx + "job/invite";

    $(function() {
        var options = {
            url: prefix + "/enterpriseList",
            modalName: "邀请情况",
            columns: [
                {
                    field : 'enterpriseId',
                    title : '企业Id',
                    visible: false
                },
                {
                    field : 'enterpriseName',
                    title : '企业名称'
                },
                {
                    field : 'inviteTime',
                    title : '邀请时间'
                },
                {
                    field : 'interviewTime',
                    title : '面试时间'
                },
                {
                    field : 'interviewPlace',
                    title : '面试地点'
                },
                {
                    field : 'operateStatus',
                    title : '处理状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field : 'operateResult',
                    title : '处理结果',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(operateResultDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="enterpriseInfo( \'' + row.enterpriseId + '\')"><i class="fa fa-edit"></i>查看企业信息</a> ');
                        if (row.operateStatus == 0) {
                            actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="changeStatus(\'' + row.inviteId + '\')"><i class="fa fa-edit"></i>同意</a> ');
                            actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)" onclick="refuse(\'' + row.inviteId + '\')"><i class="fa fa-edit"></i>拒绝</a> ');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    /** 查看企业信息*/
    function enterpriseInfo(enterpriseId) {
        /* 查看企业信息 */
        var url = ctx + 'job/positionCenter/viewEnterpriseInfo/' + enterpriseId;
        $.modal.open("投递进度", url);
    }

    /* 同意 */
    function changeStatus(inviteId) {
        $.modal.confirm("确认同意该面试邀请吗？", function() {
            $.operate.post(invitePrefix + "/changeStatus", { "inviteId": inviteId, "operateResult": 0 });
        })
    }

    /* 处理 */
    function refuse(inviteId) {
        var url = invitePrefix + '/refuseReason/' + inviteId;
        $.modal.open("拒绝", url);
    }
</script>
</body>
</html>